package com.qidian.by.search.service.impl;

import com.qidian.by.search.dto.SearchResultDTO;
import com.qidian.by.search.repository.SearchItemRepository;
import com.qidian.by.search.service.SearchItemService;
import com.qidian.by.util.pojo.EsResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-05-16 16:14
 **/
@Service
public class SearchItemServiceImpl extends SearchItemRepository {

    @Override
    public EsResult query(int page, int limit, String kw) {
        return EsResult.ok(
                "查询成功",
                new SearchResultDTO()
                        .setKw(kw)
                        .setPage(page)
                        .setLimit(limit)
                        .setRecords(listSearchItem(kw, page, limit))
                        .setTotal(selectCount(kw))
        );
    }
}
